<!DOCTYPE html>
<p>Test of createContextualFragment from a Range whose context is an XML document without a body. If the test succeeds you will see the word "PASS" below.</p>
<p id="result"></p>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

var xmlDocument = document.implementation.createDocument('http://foo.com', 'root');
var xmlRoot = xmlDocument.firstElementChild;
xmlDocument.removeChild(xmlRoot);

var range = xmlDocument.createRange();

var thrownException = null;
try {
    var fragment = range.createContextualFragment('<p id="fragment">Inserted fragment</p>');
} catch (e) {
    thrownException = e;
}

var result = document.getElementById('result');
result.textContent = thrownException ? 'FAIL' : 'PASS';
</script>
